import sys
import os
import openpyxl
import openpyxl.styles
from openpyxl.styles import PatternFill
ss=sys.argv[0].split("timeCheck")[0]
s=os.listdir(ss)

ish=0
li=[]
for i in s:
    if i.find(".xlsx")>0:
        ish+=1
        print(str(ish)+" "+ i)
        li.append(i)

xlsx=input("请选择你的文件：")

xpath=ss+"\\"+li[int(xlsx)-1]
rpath=ss+"\\deal-"+li[int(xlsx)-1]
print(xpath)
wb:openpyxl.Workbook=openpyxl.load_workbook(xpath)


from openpyxl.utils import column_index_from_string

colyello=int(column_index_from_string( input("请输入黄色统计列号(如AE):")))
colgreen=colyello+1


color45="9BBB59"
color20="FFFF00"

ish=0
for sh in wb.sheetnames:
    ish+=1
    print(str(ish)+":"+sh+"\n")
select=input("请输入表格序号：")
ws=wb[wb.sheetnames[int(select)-1]]
people=29
date=colyello-2


for i in range(1,people+1):
    if(i==1 or i==2):
        #print(str(i))
        continue
    int20=int(str("0"))
    int45=int(str("0"))
    
   
    def deal(tc,color,fgcolor,j):
        #tc.font=openpyxl.styles.Font(color=color)
        tc.fill=PatternFill("solid",fgColor=fgcolor)
        global int20
        global int45
        if j :int20+=1 
        else:int45+=1
        #print(temp[1])
    
    for j in range(1,date+1):
        
        tc=ws.cell(row=i, column=j)
        #print(str(i)+" "+str(j)+str(tc.value))
        temp=str(tc.value).split("19:")
        xmin:int=1
        if(len(temp)==2):
            xmin=int(temp[1][0])
            if xmin>2:
                deal(tc,"FFFFFF",color20,True)
                continue
        temp=str(tc.value).split("20:")
        if(len(temp)==2):
            xmin=int(temp[1][0])
            if xmin>2:
                deal(tc,"FFFFFF",color45,False)
                continue
            else:
                deal(tc,"FFFFFF",color20,True)
                continue
        temp=str(tc.value).split("21:")
        if(len(temp)==2):
            deal(tc,"FFFFFF",color45,False)
            continue
        temp=str(tc.value).split("22:")
        if(len(temp)==2):
            deal(tc,"FFFFFF",color45,False)
            continue
        temp=str(tc.value).split("23:")
        if(len(temp)==2):
            deal(tc,"FFFFFF",color45,False)
            continue
    ws.cell(i,colyello).value=str(int20)
    ws.cell(i,colgreen).value=str(int45)
    #print(str(int20)+" "+str(int45))
    #print(ws.cell(i,date+3).value)
    #print(ws.cell(i,date+4).value)
wb.save(rpath)